package twilight.companion;

import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import twilight.companion.entity.MiniYetiEntity;
import twilight.companion.event.MiniYetiSummonHandler;
import twilight.companion.init.ModEntities;
import twilight.companion.init.ModItems;
import twilight.companion.network.PacketHandler;

@Mod(TwilightCompanion.MOD_ID)
public class TwilightCompanion {
    public static final String MOD_ID = "twilight_companion";

    public TwilightCompanion() {
        IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
        
        ModEntities.register(modEventBus);
        ModItems.register(modEventBus);
        modEventBus.addListener(this::entityAttributes);

        PacketHandler.register();
        
        MinecraftForge.EVENT_BUS.register(new MiniYetiSummonHandler());
        MinecraftForge.EVENT_BUS.register(this);
    }

    @SubscribeEvent
    public void entityAttributes(EntityAttributeCreationEvent event) {
        event.put(ModEntities.MINI_YETI.get(), MiniYetiEntity.createAttributes().build());
    }
}